<?php echo $this->Html->css('Base/index'); ?>

<!-- BEGIN PAGE CONTENT-->
<div class="box">
    <div class="box-header">
        <h3 class="box-title">Users List</h3>                                    
    </div><!-- /.box-header -->

    <!-- Button Add Product -->
    <div class="btn-add-element">
		<?php echo $this->Html->link('Add', array(
                'controller' => 'users', 
                'action' => 'add'), 
                array('class' => 'btn btn-primary btn-flat')); 
                ?>
    </div>
	<!--thong bao-->
	<?php echo $this->Session->flash();?>
	<!--/thong bao-->
    <div class="box-body table-responsive">
    	<!-- BEGIN TABLE PRODUCTS LIST-->
        <table id="example1" class="table table-bordered table-striped">
            <thead>
                <tr>            
                    <th>Username</th>                                       
                    <th>Email</th>
                    <th>Role</th>
                    <th>Last login</th>
                    <th>Edit</th>
                  
                </tr>
            </thead>
            <tbody>
            	<?php foreach($data as $item){?>
                <tr>
                    <td><?php echo $item['User']['username'];?></td>
                    <td><?php echo $item['User']['email'];?></td>
                    <td>
                    	<?php 
                    	 	$grId = $item['User']['group_id'];
                    	 	if($grId == GROUP_MEMBER){
                    	 		echo "Người dùng";
                    	 	}else if($grId == GROUP_MANAGER){
                    	 		echo "Quản trị viên";
                    	 	}else{
                    	 		echo "Admin";
                    	 	}
                    	 ?>
                    	
                    </td>
                    <td><?php echo $item['User']['updated_at'];?></td>
                    <td>
                    	<?php if($grId == GROUP_MANAGER){?>
	                    	<a href="/admin/users/edit/<?php echo $item['User']['id'] ?>"><i class="fa fa-edit"></i></a>
                		<?php }?>
                    	<a href="/admin/users/delete/<?php echo $item['User']['id'] ?>" onclick="if (confirm('Bạn có muốn xóa người dùng này ?')) { return true; } return false;"><i class="fa  fa-times-circle"></i></a>
                    </td>
                </tr>
               	<?php }?>
            </tbody>
        </table>
        <!-- END TABLE PRODUCTS LIST-->
    </div><!-- /.box-body -->
     <!-- BEGIN PAGINATION -->
     <?php 
    	if ($this -> Paginator -> counter('{:pages}') > 1){
    		echo $this->element('paginationAdmin', array('Paginator' => $this->Paginator));
		}
	 ?>
 <!-- END PAGINATION -->
</div><!-- /.box -->
<!-- END PAGE CONTENT -->

<!-- page script -->
<script type="text/javascript">
	$(function() {
		$('#example1').dataTable({
                    "bPaginate": false,
                    "bLengthChange": false,
                    "bFilter": true,
                    "bSort": true,
                    "bInfo": false,
                    "bAutoWidth": false
         });
	}); 
</script>